package com.example.neo4j.repository;

import com.example.neo4j.pojo.node.Hobby;
import com.example.neo4j.pojo.node.User;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;

import java.util.List;

public interface HobbyRepository extends Neo4jRepository<Hobby, Long> {
    @Query("MATCH (n:User{account:$account})-[:Like]->(h:Hobby) RETURN h")
    List<Hobby> getMyHobby(String account);

    @Query("create (hobby:Hobby{hname:$hname,htype:$htype}) return hobby")
    Hobby addHobby(String hname, String htype);

    @Query("match (hobby:Hobby) where hobby.hname=~('.*'+$hname+'.*') return hobby")
    List<Hobby> searchHobbyByName(String hname);
}
